<!--
Copyright 2012 The Perkeep Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!doctype html>
<html>
	<head>
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=0.75">

		<link rel="shortcut icon" sizes="16x16" href="safe1-16.png">
		<link rel="shortcut icon" sizes="32x32" href="safe1-32.png">
		<link rel="apple-touch-icon" sizes="16x16" href="safe1-16.png">
		<link rel="apple-touch-icon" sizes="32x32" href="safe1-32.png">

		<script src="closure/goog/base.js"></script>
		<script src="./deps.js"></script>
		<script src="?camli.mode=config&var=CAMLISTORE_CONFIG"></script>
		<script src="react/react-with-addons.min.js"></script>
		<script src="react/react-dom.min.js"></script>
		<script src="react/classnames.js"></script>
		<script src="leaflet/leaflet.js"></script>
		<script src="leaflet/leaflet.awesome-markers.min.js"></script>
		<script src="leaflet/leaflet.markercluster.js"></script>

		<script>
			goog.DEBUG = false;
			goog.require('goog.dom');
			goog.require('goog.Uri');
			goog.require('cam.AnimationLoop');
			goog.require('cam.IndexPage');
			goog.require('cam.ServerConnection');
		</script>

		<link rel="stylesheet" href="fontawesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="opensans/OpenSans.css">
		<link rel="stylesheet" href="closure/goog/css/common.css" type="text/css">
		<link rel="stylesheet" href="leaflet/leaflet.css"/>
		<link rel="stylesheet" href="leaflet/leaflet.awesome-markers.css">
		<link rel="stylesheet" href="leaflet/MarkerCluster.css">
		<link rel="stylesheet" href="leaflet/MarkerCluster.Default.css">

		<link rel="stylesheet/less" href="index.css" type="text/css">
		<link rel="stylesheet/less" href="header.css" type="text/css">
		<link rel="stylesheet/less" href="detail.css" type="text/css">

		<link rel="stylesheet/less" href="blob_item.css" type="text/css">
		<link rel="stylesheet/less" href="blob_item_video.css" type="text/css">
		<link rel="stylesheet/less" href="blob_item_container.css" type="text/css">
		<link rel="stylesheet/less" href="blob_item_foursquare.css" type="text/css">
		<link rel="stylesheet/less" href="blob_item_mastodon.css" type="text/css">
		<link rel="stylesheet/less" href="blob_item_twitter.css" type="text/css">
		<link rel="stylesheet/less" href="blob_item_instapaper.css" type="text/css">
		<link rel="stylesheet/less" href="dialog.css" type="text/css">
		<link rel="stylesheet/less" href="permanode_detail.css" type="text/css">
		<link rel="stylesheet/less" href="property_sheet.css" type="text/css">
		<link rel="stylesheet/less" href="pyramid_throbber.css" type="text/css">
		<link rel="stylesheet/less" href="sidebar.css" type="text/css">
		<link rel="stylesheet/less" href="tags_control.css" type="text/css">
		<script src="less/less.js"></script>
		<script src="goui.js"></script>
	</head>
	<body class="cam-index-page">
    <div class="cam-index-page--container"></div>
		<script>
			var lastWidth = -1;
			var lastHeight = -1;
			var render = function() {
				var currentWidth = document.documentElement.offsetWidth;
				var currentHeight = window.innerHeight;
				if (currentWidth == lastWidth && currentHeight == lastHeight) {
					return;
				}

				lastWidth = currentWidth;
				lastHeight = currentHeight;

				var container = document.body.getElementsByClassName('cam-index-page--container').item(0);
				if (!container) {
					console.log("cam-index-page: couldn't find mount point for root")
					return;
				}
				var index = React.createElement(cam.IndexPage, {
					availWidth: currentWidth,
					availHeight: currentHeight,
					config: CAMLISTORE_CONFIG,
					eventTarget: window,
					history: window.history,
					openWindow: function(url) { return window.open(url); },
					location: window.location,
					scrolling: {
						target: window,
						// Note that calling get() can cause layout, so should be used only once per scroll event.
						get: function() { return goog.dom.getDocumentScrollElement().scrollTop; },
						set: function(val) { goog.dom.getDocumentScrollElement().scrollTop = val; },
					},
					serverConnection: new cam.ServerConnection(CAMLISTORE_CONFIG),
					timer: window,
				});
				ReactDOM.render(index, container);
			};
			window.addEventListener('resize', render);
			window.setInterval(render, 3000);
			render();
		</script>
	</body>
</html>
